
//
//  AboutViewController.m
//  Cat
//
//  Created by lushitong on 2018/12/1.
//  Copyright © 2018年 lushitong. All rights reserved.
//

#import "AboutViewController.h"
#import "FLTool.h"

static NSString *infoString = @" 喵象分享社交电商开创者。来喵象复制商品标题搜索商品的隐藏优惠券，你会发现意想不到的商品超低价！我们拥有巨多的淘宝、天猫、JD等网购平台购物优惠券，您还可以在独家“拼便宜”频道购买到超低价优质进口商品。喵象分享社交电商开创线上线下购物的新形态，您可以充分发挥好友或粉丝裂变的巨大能量，让她们在省钱购物的同时为你赚到多笔佣金，实现互惠共赢。不仅如此，喵象还实现让线上店铺，实体商家、消费者一起加入，多方共赢。欢迎加入喵象大家庭，共创美好生活！如何在喵象购物？第一步：在淘宝、天猫、JD等购物平台挑选心仪商品。第二步：复制商品标题到喵象搜索优惠券。第三步：购物下单直接抵扣优惠券。第四步：分享给好友购买赚取佣金！";

@interface AboutViewController ()

@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *appNameLabel;
@property (nonatomic, strong) UILabel *infoLabel;
@property (nonatomic, strong) UILabel *versionLabel;


@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	[self.topTitleView setDetailDic:@{Nav_Title:@"关于我们"}.mutableCopy];
	[self addAllSubViews];
}


- (void)addAllSubViews {
	[self.view addSubviews:@[self.iconImageView,self.appNameLabel,self.infoLabel,self.versionLabel]];
	
	[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.size.equalTo(CGSizeMake(kQKFitModule(80), kQKFitModule(80)));
		make.centerX.equalTo(self.view.mas_centerX);
		make.top.equalTo(self.topTitleView.mas_bottom).offset(kQKFitModuleDecimal(30));
	}];
	
	[self.appNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(self.iconImageView.mas_centerX);
		make.top.equalTo(self.iconImageView.mas_bottom).offset(kQKFitModuleDecimal(9));
	}];
	
	[self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.equalTo(self.view.mas_left).offset(kQKFitModuleDecimal(16));
		make.right.equalTo(self.view.mas_right).offset(-kQKFitModuleDecimal(16));
		make.top.equalTo(self.appNameLabel.mas_bottom).offset(kQKFitModuleDecimal(21));
	}];
	
	[self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(self.iconImageView.mas_centerX);
		make.bottom.equalTo(self.view.mas_bottom).offset(-kQKFitModuleDecimal(42));
	}];
}

#pragma mark----- lazy init -----

- (UIImageView *)iconImageView {
	if (!_iconImageView) {
		_iconImageView = [[UIImageView alloc] init];
		_iconImageView.image = [UIImage imageNamed:@"app_icon"];
	}
	return _iconImageView;
}

- (UILabel *)appNameLabel {
	if (!_appNameLabel) {
		_appNameLabel = [UILabel labelWithText:@"喵象" font:[UIFont systemFontOfSize:16 * SWScaleFromInch47] textColor:	COLOR_WITH_HEX(0xFFC236)];
	}
	return _appNameLabel;
}

- (UILabel *)infoLabel {
	if (!_infoLabel) {
		_infoLabel = [UILabel labelWithText:infoString font:[UIFont systemFontOfSize:12 * SWScaleFromInch47] textColor:COLOR_WITH_HEX(0x57524F)];
		NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:infoString attributes:@{}];
		NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
		[paragraphStyle setLineSpacing:8];//行间距
		[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [infoString length])];
		[_infoLabel setAttributedText:attributedString];
		
		_infoLabel.numberOfLines = 0;
	}
	return _infoLabel;
}

- (UILabel *)versionLabel {
	if (!_versionLabel) {
		_versionLabel = [UILabel labelWithText:[FLTool getBundleVersion] font:[UIFont systemFontOfSize:kQKFitFont(12)] textColor:COLOR_WITH_HEX(0x57524F)];
	}
	return _versionLabel;
}

@end
